package wzvtc.dbad.attend.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wzvtc.dbad.attend.entity.Attendant;
import wzvtc.dbad.attend.entity.AttendenceDetail;
import wzvtc.dbad.attend.entity.Student;
import wzvtc.dbad.attend.repo.StudentRepository;
import wzvtc.dbad.attend.vo.ExtendAttendence;
import wzvtc.dbad.attend.vo.ExtendCurriculum;

import java.util.List;

@RestController
@RequestMapping("/attender")
public class AttendComtroller {

    @Autowired
    StudentRepository repository;


    /**
     * 根据考勤员id获取考勤员的完整信息
     *
     * @param id 考勤员id
     * @return 考勤员对象
     */

    @GetMapping("{id}")
    Attendant fetchAttender(@PathVariable long id) {
        //TODO
        return null;//this.repository.save(new Student(name));
    }


    /**
     * 返回该班级中所有同学的信息
     *
     * @param clazzId 班级id
     * @return
     */
    @GetMapping("studentsByClazzId/{clazzId}")
    List<Student> fetchStudentsByClazzId(@PathVariable long clazzId) {
        //TODO
        return null;
    }


    /**
     * 保存新的已确认考勤表
     *
     * @param curriculumId
     * @return 新建考勤表的id
     */
    @PostMapping("newConfirmedAttendenceWithcurriculumId/{curriculumId}")
    Long fetchStudentsByClazzId(@RequestBody List<AttendenceDetail> attendDetailList, @PathVariable long curriculumId) {
        //TODO 请首先获取curriculum对象，再设置Attendence对象，并设置所有AttendenceDetail对象的parent对象。
        //最后保存所有新对象
        //并返回Attendence对象的id
        return null;
    }


    /**
     * @param {*} clazz_id 根据班级id获得该班级所有考勤表(根据授课时间倒序排列)
     * @returns
     */
    @GetMapping("attendencesOfClazzId/{clazzId}")
    List<ExtendAttendence> fetchAttendencesOfClazzId(@PathVariable long clazzId) {
        //TODO 记得倒序排列
        return null;
    }


}
